﻿using System.IO;
using System.Windows.Forms;

using Org.BouncyCastle.Pkcs;

namespace iSonar.iCarus.Gui.Controls {
  public partial class Pkcs12ViewCtrl : UserControl {
    public Pkcs12ViewCtrl() {
      InitializeComponent();
    }

    private void loadPkcs12(string fileName, string password) {
      using (Stream _p12s = File.OpenRead(fileName)) {
        Pkcs12Store _p12 = new Pkcs12Store(_p12s,password.ToCharArray());
        foreach (string _alias in _p12.Aliases) {
          if (_p12.IsCertificateEntry(_alias)) {
            X509CertificateEntry[] _certs = _p12.GetCertificateChain(_alias);
          }
          if (_p12.IsKeyEntry(_alias)) {
            AsymmetricKeyEntry _key = _p12.GetKey(_alias);
          }
        }
      }
    }

  }
}
